# login.py
from aaa.api.base_api import BaseAPI


class Login(BaseAPI):

    def login(self, data_login):
        url_login = f'{self.BASE_URL}/login/verifyLogin'
        response = self.session.get(url_login, params=data_login)
        return self._handle_response(response, '登录')

    def login_admin(self):
        data_admin = {
            "username": "admin",
            "password": "123456"
        }
        url_login = f'{self.BASE_URL}/login/verifyLogin'
        response = self.session.get(url_login, params=data_admin)
        return self._handle_response(response, '管理员登录')

    def login_missing_value(self, data_login):
        url_login = f'{self.BASE_URL}/login/verifyLogin'
        response = self.session.get(url_login, params=data_login)
        return self._handle_response(response, '参数缺失登录')

    def login_missing_key(self, data_login):
        url_login = f'{self.BASE_URL}/login/verifyLogin'
        response = self.session.get(url_login, params=data_login)
        return self._handle_response(response, '键缺失登录')

    def sql_injection_test(self, data_login):
        url_login = f'{self.BASE_URL}/login/verifyLogin'
        response = self.session.get(url_login, params=data_login)
        return self._handle_response(response, 'SQL注入测试')


if __name__ == '__main__':
    login = Login()
    data_login = {
        'username': 'admin',
        'password': 'admin'
    }
    print(login.login(data_login))
    print(login.login_admin())
    print(login.login_missing_key(data_login))
    print(login.login_missing_value(data_login))
    print(login.sql_injection_test(data_login))